feedback-vos 1.0.39 → 1.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -271,8 +271,21 @@ function ScreenshotEditor({
271
271
  const editedScreenshot = canvas.toDataURL("image/png");
272
272
  onSave(editedScreenshot);
273
273
  };
274
- const maxWidth = 600;
275
- const displayWidth = image ? Math.min(maxWidth, image.width) : maxWidth;
274
+ const [maxDisplayWidth, setMaxDisplayWidth] = react$1.useState(600);
275
+ react$1.useEffect(() => {
276
+ const updateMaxWidth = () => {
277
+ if (window.innerWidth >= 768) {
278
+ const availableWidth = window.innerWidth * 0.9 - 64;
279
+ setMaxDisplayWidth(Math.max(1200, Math.min(availableWidth, 1600)));
280
+ } else {
281
+ setMaxDisplayWidth(600);
282
+ }
283
+ };
284
+ updateMaxWidth();
285
+ window.addEventListener("resize", updateMaxWidth);
286
+ return () => window.removeEventListener("resize", updateMaxWidth);
287
+ }, []);
288
+ const displayWidth = image ? Math.min(maxDisplayWidth, image.width) : maxDisplayWidth;
276
289
  const displayHeight = image ? displayWidth / image.width * image.height : 400;
277
290
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `fixed inset-0 z-50 flex items-center justify-center ${themeClasses.overlay} p-2 md:p-4`, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${themeClasses.bgSecondary} rounded-lg shadow-xl max-w-4xl w-full max-h-[95vh] md:max-h-[90vh] overflow-auto`, children: [
278
291
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `sticky top-0 ${themeClasses.bgSecondary} border-b ${themeClasses.borderPrimary} p-2 md:p-4 flex items-center justify-between z-10 gap-2`, children: [
@@ -390,21 +403,55 @@ function ScreenshotButton({
390
403
  const canvas = await html2canvas__default.default(document.body, {
391
404
  width: window.innerWidth,
392
405
  height: window.innerHeight,
393
- scrollX: -window.scrollX,
394
- scrollY: -window.scrollY,
395
406
  windowWidth: window.innerWidth,
396
407
  windowHeight: window.innerHeight,
397
- scale: window.devicePixelRatio || 1,
398
- // Use device pixel ratio for better quality
408
+ scrollX: -window.scrollX,
409
+ scrollY: -window.scrollY,
410
+ scale: 1,
411
+ // Use scale 1 for consistent sizing
399
412
  useCORS: true,
400
- // Enable CORS for better image rendering
413
+ allowTaint: true,
414
+ // Allow external images for better rendering
415
+ backgroundColor: null,
416
+ // Preserve page background
417
+ removeContainer: false,
418
+ // Maintain proper container rendering
401
419
  logging: false,
402
- // Disable logging for cleaner output
403
420
  ignoreElements: (element) => {
404
421
  return element.hasAttribute("data-feedback-widget") || element.closest("[data-feedback-widget]") !== null;
405
422
  }
406
423
  });
407
- const base64image = canvas.toDataURL("image/png", 1);
424
+ const targetWidth = 1920;
425
+ const targetHeight = 1080;
426
+ const normalizedCanvas = document.createElement("canvas");
427
+ normalizedCanvas.width = targetWidth;
428
+ normalizedCanvas.height = targetHeight;
429
+ const ctx = normalizedCanvas.getContext("2d");
430
+ if (!ctx) {
431
+ setIsTakenScreenShot(false);
432
+ return;
433
+ }
434
+ ctx.imageSmoothingEnabled = true;
435
+ ctx.imageSmoothingQuality = "high";
436
+ const sourceAspect = canvas.width / canvas.height;
437
+ const targetAspect = targetWidth / targetHeight;
438
+ let drawWidth = targetWidth;
439
+ let drawHeight = targetHeight;
440
+ let drawX = 0;
441
+ let drawY = 0;
442
+ if (sourceAspect > targetAspect) {
443
+ drawHeight = targetHeight;
444
+ drawWidth = drawHeight * sourceAspect;
445
+ drawX = (targetWidth - drawWidth) / 2;
446
+ } else {
447
+ drawWidth = targetWidth;
448
+ drawHeight = drawWidth / sourceAspect;
449
+ drawY = (targetHeight - drawHeight) / 2;
450
+ }
451
+ ctx.fillStyle = "#ffffff";
452
+ ctx.fillRect(0, 0, targetWidth, targetHeight);
453
+ ctx.drawImage(canvas, drawX, drawY, drawWidth, drawHeight);
454
+ const base64image = normalizedCanvas.toDataURL("image/png", 1);
408
455
  onScreenshotTook(base64image);
409
456
  setIsTakenScreenShot(false);
410
457
  }
@@ -754,7 +801,7 @@ async function uploadFileToRepo(token, owner, repo, file, folderPath, defaultBra
754
801
  return rawUrl;
755
802
  }
756
803
  async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshotPath) {
757
- const compressedScreenshot = await compressScreenshot(screenshot, 2560, 0.9);
804
+ const compressedScreenshot = await compressScreenshot(screenshot, 1920, 0.85);
758
805
  const base64Content = compressedScreenshot.includes(",") ? compressedScreenshot.split(",")[1] : compressedScreenshot;
759
806
  const repoResponse = await fetch(
760
807
  `https://api.github.com/repos/${owner}/${repo}`,
@@ -856,7 +903,7 @@ async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshot
856
903
  console.log(`Screenshot uploaded successfully to: ${rawUrl}`);
857
904
  return rawUrl;
858
905
  }
859
- function compressScreenshot(dataUrl, maxWidth = 2560, quality = 0.9) {
906
+ function compressScreenshot(dataUrl, maxWidth = 1920, quality = 0.85) {
860
907
  return new Promise((resolve, reject) => {
861
908
  if (typeof window === "undefined" || typeof document === "undefined") {
862
909
  reject(new Error("Screenshot compression only works in browser environments"));
@@ -871,9 +918,8 @@ function compressScreenshot(dataUrl, maxWidth = 2560, quality = 0.9) {
871
918
  height = height * maxWidth / width;
872
919
  width = maxWidth;
873
920
  }
874
- const dpr = window.devicePixelRatio || 1;
875
- canvas.width = width * dpr;
876
- canvas.height = height * dpr;
921
+ canvas.width = width;
922
+ canvas.height = height;
877
923
  const ctx = canvas.getContext("2d");
878
924
  if (!ctx) {
879
925
  reject(new Error("Could not get canvas context"));
@@ -881,7 +927,6 @@ function compressScreenshot(dataUrl, maxWidth = 2560, quality = 0.9) {
881
927
  }
882
928
  ctx.imageSmoothingEnabled = true;
883
929
  ctx.imageSmoothingQuality = "high";
884
- ctx.scale(dpr, dpr);
885
930
  ctx.drawImage(img, 0, 0, width, height);
886
931
  const compressedDataUrl = canvas.toDataURL("image/jpeg", quality);
887
932
  resolve(compressedDataUrl);